/* ----< START >----- CLASS FCColors -----------------------------------------------------------
 * This class contains an array of colors to be used as default set of colors for FusionCharts
 * arr_FCColors is the array that would contain the hex code of colors 
 * ALL COLORS HEX CODES TO BE USED WITHOUT #
 *
 * Modified 16 June 2011
 * Added option to provide custom color for sets
 *
*/
infosoftglobal.FusionChartsUtil.FCColors = function(strColors){
        this.arr_FCColors=[ "AFD8F8","F6BD0F" ,"8BBA00" , "A66EDD", "F984A1", "CCCC00", "999999","0099CC" ,  "FF0000", "006F00","0099FF" , "FF66CC", "669966", "7C7CB4", "FF9933", "9900FF", "99FFCC","CCCCFF","669900" ,"1941A5"];
        this.randomize=false;// takes 1=true or 0=false
        if (strColors!=null && strColors!="" && typeof strColors!="undefined") this.addColors(strColors);
        this.FCColorIndex= -1;

}
infosoftglobal.FusionChartsUtil.FCColors.prototype = {
        //nextColor() method returns a color from arr_FCColors array. It uses
        //cyclic iteration to return a color from a given index. The index value is
        //maintained in this.FCColorindex
        nextColor: function(){
            var strColor;
            
            if (!this.randomize)
            {    
                strColor=this.arr_FCColors[ (++this.FCColorIndex) % (this.arr_FCColors.length-1) ];
            }
            else
            {
                strColor=this.arr_FCColors[ Math.floor(Math.random() * (this.arr_FCColors.length))];
            }
            this.userColor = strColor;
            
            console.log(this.FCColorIndex + " : " + strColor );
            return strColor;
        },
        addColors: function(strColors){
            strColors=strColors.replace(/\s/ig,"");
            strColors=strColors.replace(/[^a-f^0-9^\;^\+]/ig,"");
            
            console.log(strColors);

            if(strColors.search(/^\+|\+$/g)<0)
            {
                this.arr_FCColors = strColors.split(";");
            }
            else
            {
                if(strColors.indexOf("+")==strColors.length-1)
                {
                    this.arr_FCColors = (strColors.replace(/\+/g,"")+";"+ this.arr_FCColors.join(";")).split(";");
                }
                else
                {
                    if(strColors.indexOf("+")==0)
                    {
                        this.arr_FCColors = (this.arr_FCColors.join(";")+";"+strColors.replace(/\+/g,"")).split(";");
                    }
                }

            }
            
            console.log(this.arr_FCColors.join(";"));
            
        },
        resetIndex: function(){
            this.FCColorIndex= -1  ;
        },
        
        toString : function(){
            return this.userColor;
        }

}
/* --< END >--------- CLASS FCColor -----------------------------------------------------------*/
/* Aliases for easy usage */
var FCColors = infosoftglobal.FusionChartsUtil.FCColors ;

